package tj.eskhata.pos.services;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import org.hibernate.criterion.Criterion;
import org.springframework.transaction.annotation.Transactional;

import tj.eskhata.pos.common.SBRate;
import tj.eskhata.pos.dao.AccDao;
import tj.eskhata.pos.dao.AccTargetDao;
import tj.eskhata.pos.dao.BankDao;
import tj.eskhata.pos.domain.Acc;
import tj.eskhata.pos.domain.AccTarget;
import tj.eskhata.pos.domain.Bank;
import tj.eskhata.pos.domain.CertType;
import tj.eskhata.pos.domain.Certificate;
import tj.eskhata.pos.domain.ClPart;
import tj.eskhata.pos.domain.ClPoint;
import tj.eskhata.pos.domain.Client;
import tj.eskhata.pos.domain.Country;
import tj.eskhata.pos.domain.PsDoctrans;
import tj.eskhata.pos.domain.Region;
import tj.eskhata.pos.domain.Sost;
import tj.eskhata.pos.domain.SprNp;
import tj.eskhata.pos.domain.SprPaySystem;
import tj.eskhata.pos.domain.Sprval;
import tj.eskhata.pos.domain.Status;
import tj.eskhata.pos.domain.Tarif;
import tj.eskhata.pos.domain.Town;
import tj.eskhata.pos.domain.TypeAcc;
import tj.eskhata.pos.domain.User;

//import wicket.in.action.chapter13.dbdiscounts.domain.Cheese;
//import wicket.in.action.chapter13.dbdiscounts.domain.Discount;
//import wicket.in.action.chapter13.dbdiscounts.domain.User;

public interface PosService {

  <T> T load(Class<T> type, long id);
  <T> List<T> findByCriteria(Class<T> type, Criterion... criterion);
  
  List<Acc> findAllAccs();
  List<Acc> findByCriteriaAcc(Criterion... criterion);
  void saveAcc(Acc acc);
  void deleteAcc(Acc acc);
  AccDao getAccDao();
  Long getAccPsAcc(String codeAcc, Long paySysId, Long ftMoneyId, Long partId, Long accTarget);
  Long getAcc(String codeAcc, Long ftMoneyId, Long partId,Long accPartId, Long accPointId);
  
  List<AccTarget> findAllAccTarget();
  void saveAccTarget(AccTarget accTarget);
  void deleteAccTarget(AccTarget accTarget);
  AccTargetDao getAccTargetDao();
  
  List<Bank> findAllBanks();
  void saveBank(Bank bank);
  void deleteBank(Bank bank);
  BankDao getBankDao();
  
  List<Certificate> findAllCertificates();
  List<Certificate> findByCriteriaCertificate(Criterion... criterion);
  void saveCertificate(Certificate certificate);
  Certificate saveCertificateExt(Certificate certificate);
  void deleteCertificate(Certificate certificate);
  
  List<CertType> findAllCertTypes();
  List<CertType> findByCriteriaCertType(Criterion... criterion);
  void saveCertType(CertType certType);
  void deleteCertType(CertType certType);
  
  List<Client> findAllClients();
  void saveClient(Client client);
  @Transactional
  Client saveClientExt(Client client);
  void deleteClient(Client client);
  List<Client> criteriaByNameClient(String name,String pasp, Integer num);
  List<Client> findByCriteriaClient(Criterion... criterion);
  
  
  List<ClPart> findAllClParts();
  List<ClPart> findByCriteriaClPart(Criterion... criterion);
  void saveClPart(ClPart clPart);
  void deleteClPart(ClPart clPart);
  Date getOpDateClPart(Long clPartId);
  
  List<ClPoint> findAllClPoints();
  List<ClPoint> findByCriteriaClPoint(Criterion... criterion);
  void saveClPoint(ClPoint clPoint);
  void deleteClPoint(ClPoint clPoint);

  List<Country> findAllCountries();
  List<Country> findAllCountries(String order);
  List<Country> findByCriteriaCountry(Criterion... criterion);  
  void saveCountry(Country country);
  void deleteCountry(Country country);
  
  
// PSDoctrans
  
  List<PsDoctrans> findAllPsDoctrans();
  List<PsDoctrans> findByCriteriaPsDoctrans(Criterion... criterion);  
  void savePsDoctrans(PsDoctrans psDocument);
  PsDoctrans savePsDoctransExt(PsDoctrans psDocument);
  void deletePsDoctrans(PsDoctrans psDocument);
  void toConfirm(PsDoctrans object,Date datConf, Long userId);
  List<PsDoctrans> getJornalPsDoctrans(Date bdate,Date edate,Long point, Long part);
  List<PsDoctrans> getCommitedPsDoctrans(Date bdate,Date edate,Long point, Long part, String clName, String docNum, Long userId);
  Object getRepPSysPsDoctrans(Date bdate,Date edate,Long point, Long part, Long pSysId, Long valId, String sostCode);
  List<Long> getDosyeClientsPsDoctrans(Date bdate,Date edate,Long partId, Long sostId);
  int validateCancelPsDoctrans(PsDoctrans object);
  void toCancelPsDoctrans(PsDoctrans object, Long userId);
  
  
  List<Region> findAllRegions();
  List<Region> findByCriteriaRegion(Criterion... criterion);
  void saveRegion(Region region);
  void deleteRegion(Region region);
  
  List<Sost> findAllSosts();
  List<Sost> findByCriteriaSost(Criterion... criterion);
  void saveSost(Sost sost);
  void deleteSost(Sost sost);
  Sost getSost(String code);
  
  List<SprPaySystem> findAllSprPaySystems();
  List<SprPaySystem> findByCriteriaPaySystem(Criterion... criterion);
  void saveSprPaySystem(SprPaySystem sprPaySystem);
  void deleteSprPaySystem(SprPaySystem sprPaySystem);
  
  List<Sprval> findAllSprvals();
  List<Sprval> findByCriteriaVal(Criterion... criterion);
  void saveSprval(Sprval sprval);
  void deleteSprval(Sprval sprval);
  SBRate GetSBRateSprval(Long ftMoney, Date onDate);
  
  List<SprNp> findAllSprNps();
  List<SprNp> findByCriteriaSprNp(Criterion... criterion);
  void saveSprNp(SprNp sprNp);
  void deleteSprNp(SprNp sprNp);
  
  List<Status> findAllStatuses();
  List<Status> findByCriteriaStatus(Criterion... criterion);
  void saveStatus(Status status);
  void deleteStatus(Status status);

  BigDecimal getSumKomiss(BigDecimal summa_, Long tarif_, Date date_, ClPart part_, Sprval sprVal_);
  
  List<Town> findAllTowns();
  List<Town> findByCriteriaTown(Criterion... criterion);
  void saveTown(Town town);
  void deleteTown(Town town);
  
  List<TypeAcc> findAllTypeAccs();
  void saveTypeAcc(TypeAcc typeAcc);
  void deleteTypeAcc(TypeAcc typeAcc);
    
  List<User> findAllUsers();
  List<User> findByCriteriaUser(Criterion... criterion);
  void saveUser(User user);
  void deleteUser(User user);
  boolean isUserInGroupUser(User user, String groupCode);
  



  //@Transactional
  //void saveDiscounts(List<Discount> discounts);


  
}
